package com.mdd.admin.controller.system;

import com.mdd.admin.config.aop.Log;
import com.mdd.admin.service.system.ISystemDevPayWayService;
import com.mdd.admin.validate.course.CourseParam;
import com.mdd.admin.validate.system.SystemDevPayWayParam;
import com.mdd.admin.validate.common.PageParam;
import com.mdd.admin.validate.system.SystemDevPayWayUpdateParam;
import com.mdd.admin.vo.system.SystemDevPayWayListVo;
import com.mdd.admin.vo.system.SystemDevPayWayDetailVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 支付方式管理
 * @author panweiliang
 */
@RestController
@RequestMapping("api/system/payway")
public class SystemDevPayWayController {

    @Resource
    ISystemDevPayWayService iSystemDevPayWayService;

    /**
     * 支付方式列表
     *
     * @author panweiliang
     * @return Object
     */
    @GetMapping("/list")
    public Object list() {
        return AjaxResult.success(iSystemDevPayWayService.list());
    }

    /**
     * 修改支付方式
     * @author panweiliang
     * @param systemDevPayWayUpdateParam 支付方式id
     * @return AjaxResult
     */
    @Log(title = "支付方式批量修改")
    @PostMapping("/update")
    public AjaxResult setup(@Validated(value = SystemDevPayWayUpdateParam.update.class) @RequestBody SystemDevPayWayUpdateParam systemDevPayWayUpdateParam) {
        iSystemDevPayWayService.update(systemDevPayWayUpdateParam);
        return AjaxResult.success();
    }

    /**
     * 支付状态
     * @author panweiliang
     * @param id 支付方式id
     * @return AjaxResult
     */
    @Log(title = "支付方式状态切换")
    @PostMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestParam(value = "id") Integer id) {
        return AjaxResult.success(iSystemDevPayWayService.changeStatus(id));
    }


    /**
     * 设置为默认支付方式
     * @author panweiliang
     * @param id 支付方式id
     * @return AjaxResult
     */
    @Log(title = "设置支付方式为默认")
    @PostMapping("/setAsDefault")
    public  public AjaxResult setAsDefault(@RequestParam(value = "id"), String newParam89 Integer id) {
        return AjaxResult.success(iSystemDevPayWayService.changeAsDefault(id));
    }

}
